# 页面类
from Base.Base import Base
from selenium.webdriver.common.by import By
import time
class Page2(Base):
    # 1.点击登录按钮
    login_loc = (By.LINK_TEXT, '登录')
    def login(self):
        self.click(self.login_loc)
    # 2.输入用户名
    user_loc = (By.XPATH, '//input[contains(@id,"TANGRAM__PSP_11__userName")]')

    def user(self):
        self.send_keys(self.user_loc, '19525482253')

    # 3.输入密码
    passw_loc = (By.XPATH, '/html/body/div[5]/div[2]/div[2]/div/div/div/div/div/div[1]/div[2]/form/p[4]/input[2]')

    def passw(self):
        self.send_keys(self.passw_loc, 'zzd040708')

    # 4.点击协议
    xieyi_loc = (By.NAME, 'isAgree')

    def xieyi(self):
        self.click(self.xieyi_loc)

    # 5.点击登录按钮
    login1_loc = (By.XPATH, '//input[starts-with(@id,"TANGRAM__PSP_11__submit")]')

    def login1(self):
        self.click(self.login1_loc)
    # 6.设置悬停
    moves_loc=(By.XPATH,'/html/body/div/div[2]/div[3]/span[2]')
    def moves(self):
        self.move(self.moves_loc)
    # 7.高级搜索
    g_search_loc=(By.CLASS_NAME,'set')
    def g_search(self):
        self.click(self.g_search_loc)
    # 断言
    dy3_loc=(By.XPATH,'/html/body/div[1]/div[6]/div/div/div/div[3]/div/form/ul/li[1]/span')
    def dy3(self):
        return self.text(self.dy3_loc)
    # 8.包含全部关键字
    gjz_loc=(By.ID,'adv_keyword')
    def gjz(self):
        self.send_keys(self.gjz_loc,'web')
    # 9.包含完成关键词
    wc_gjz_loc=(By.XPATH,'/html/body/div/div[6]/div/div/div/div[3]/div/form/ul/li[1]/div[2]/input')
    def wc_gjz(self):
        self.send_keys(self.wc_gjz_loc,'web')
    # 10.点击高级搜索
    gj_search_loc=(By.XPATH,'/html/body/div/div[6]/div/div/div/div[3]/div/form/ul/li[6]/div/input[2]')
    def gj_search(self):
        self.click(self.gj_search_loc)


    def luoji_03_login_search(self):
        self.open_url('https://www.baidu.com/')
        # 1.点击登录按钮
        self.login()
        # 2.输入用户名
        self.user()
        # 3.输入密码
        self.passw()
        time.sleep(3)
        # 4.点击协议
        self.xieyi()
        # 5.点击登录按钮
        self.login1()
        time.sleep(3)
        # 6.设置悬停
        self.moves()
        time.sleep(3)
        # 7.高级搜索
        self.g_search()
        # 断言
        print(self.dy3())
        assert "搜索结果" in self.dy3()
        # 8.包含全部关键字
        self.gjz()
        time.sleep(2)
        # 9.包含完成关键词
        self.wc_gjz()
        time.sleep(2)
        # 10.点击高级搜索
        self.gj_search()
        time.sleep(3)